package com.lino.design;

import java.math.BigDecimal;

/**
 * @description: 策略控制类
 * @author: lingjian
 * @createDate: 2023/2/9 16:37
 */
public class Context<T> {

    private ICouponDiscount<T> couponDiscount;

    public Context(ICouponDiscount<T> couponDiscount) {
        this.couponDiscount = couponDiscount;
    }

    /**
     * 计算优惠券折扣
     *
     * @param couponInfo 优惠券信息泛型
     * @param skuPrice   商品价格
     * @return 优惠券折扣后的价格
     */
    public BigDecimal discountAmount(T couponInfo, BigDecimal skuPrice) {
        return couponDiscount.discountAmount(couponInfo, skuPrice);
    }
}
